/**
*  排班类型
*/
import React from 'react';
import { Card, Table, Input, Form, Select, DatePicker, Button, Popconfirm, Icon, message, Checkbox, Badge, Tabs } from 'antd';
import { $http } from 'containers/config/https';
import { Util } from 'tools/index';
import { dayFormat } from 'tools/index';
import moment from 'moment';
import store from 'store';
import CommonPagination from 'components/pagination/index';
import './style/index.less';

const { TabPane } = Tabs;
const Option = Select.Option;
// const doctorImg = require('./image/doctor.png');

class Scheduling extends React.Component {
    constructor(props) {
        super(props)
        var userData = JSON.parse(sessionStorage.getItem('userData'))
        this.state = {
            hospital: [],
            dataSource: [],
            sumData: [],
            isShowEditModal: false,
            hospitalData: [],
            drActiveData: [],
            total: 0,
            page: 1,
            pageSize: 10,
            modalData: {},
            userData: userData,
            leftRowData: {},
            associateDta: [],
            checked: true,
            size: 'small',
            expenseType: '1'
        }
    }

    componentDidMount() {
        this.loadData();//初始化排版类型数据
        this.initData();//初始化列
        this.loadHospitalMsg();//获取医院信息
        this.loadProjectData();//获取项目名称数据
    }

    initData() {
        this.columns = [
            {
                title: '项目代码',
                dataIndex: 'code',
                width: 120,
                align: 'center'
            },
            {
                title: '项目名称',
                dataIndex: 'descripts',
                width: 120,
                align: 'center'
            }, {
                title: '生效日期',
                dataIndex: 'startDate',
                width: 120,
                align: 'center'
            }, {
                title: '失效日期',
                dataIndex: 'stopDate',
                width: 120,
                align: 'center'
            },
            {
                title: '项目单价',
                dataIndex: 'price',
                width: 120,
                align: 'center'
            }, {
                title: '操作',
                dataIndex: 'opertion',
                width: 120,
                align: 'center',
                render: (text, data) => {
                    return (
                        <span>
                            {/* <Icon type="edit" style={{ color: '#108EE9' }}></Icon>
                            <span className='span' onClick={this.editRightData.bind(this, data)}>编辑</span>
                            <Divider type="vertical" /> */}
                            <Icon type="delete" style={{ color: 'rgba(240,65,52,1)' }}></Icon>
                            <Popconfirm title="删除不可恢复，你确定要删除吗?" onConfirm={this.handleRightDel.bind(this, data)} >
                                <span className='span' style={{ color: 'rgba(240,65,52,1)' }}>删除</span>
                            </Popconfirm>
                        </span >
                    )
                }
            }
        ];

        this.sumSolumns = [
            {
                title: '医院代码',
                dataIndex: 'hospCode',
                width: 120,
                align: 'center'
            }, {
                title: '医院名称',
                dataIndex: 'hospDescripts',
                width: 120,
                align: 'center'
            }, {
                title: '操作',
                dataIndex: 'operation',
                width: 120,
                align: 'center',
                render: (text, data) => {
                    return (
                        <Popconfirm title="删除不可恢复，你确定要删除吗?" onConfirm={() => this.handleRelationDel(data)} >
                            <span className="span">删除</span>
                        </Popconfirm>
                    )
                }
            },
        ];

        this.leftColumn = [
            {
                title: '代码',
                dataIndex: 'code',
                width: 120,
                align: 'left',
                render: (text, data) => {
                    return <span className={data.activeFlag == '1' ? '' : 'active-color'}>{data.code}</span>
                }
            }, {
                title: '类型名称',
                dataIndex: 'descripts',
                width: 120,
                align: 'left',
                render: (text, data) => {
                    return <span className={data.activeFlag == '1' ? '' : 'active-color'}>{data.descripts}</span>
                }
            }, {
                title: '状态',
                dataIndex: 'status',
                width: 80,
                align: 'left',
                render: (text, data) => {
                    return <Badge status={data.activeFlag == '1' ? 'success' : 'error'} text={data.activeFlag == '1' ? '有效' : '失效'}></Badge>
                }
            }, {
                title: '操作',
                dataIndex: 'operstation',
                width: 120,
                align: 'left',
                render: (text, data) => {
                    return (
                        <span>
                            {/* <Icon type="edit" className={'active-edit'}></Icon>
                            <span className={'active-edit'} onClick={this.editData.bind(this, data)}>编辑</span>
                            <Divider type="vertical" /> */}
                            <Icon type="delete" style={{ color: 'rgba(240,65,52,1)' }}></Icon>
                            <Popconfirm title="删除不可恢复，你确定要删除吗?" onConfirm={this.handleDel.bind(this, data)} >
                                <span className='span' style={{ color: 'rgba(240,65,52,1)' }}>删除</span>
                            </Popconfirm>
                        </span >
                    )
                }
            }
        ]
    }

    //修改
    editData(data) {
        this.setState({
            editData: data,
            code: '',
            descripts: '',
            editStatus: true
        })
    }

    editRightData(data) {
        this.setState({
            rightStartDate: '',
            rightStopDate: '',
            startStatus: false,
            endStatus: false,
            editRightData: data,
        })
    }

    handleRightDel(data) {
        const { expenseType, rightId } = this.state;
        var params = {
            params: [
                {
                    id: data.id,
                    userID: this.state.userData.userID//createUserDr -->userID
                },
            ],
        }
        $http.post('urlDeault', this, {
            code: expenseType === '1' ? '03020006' : '03020065',
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    message.success('删除成功！')
                    this.loadAssociated()
                    if (rightId && data.id === rightId) {
                        this.clearRightInput();
                    }
                }
            }
        });
    }

    loadProjectData(id) {
        var params = {
            params: [{
                hospID: id ? id : this.state.userData.hospID
            }],
        }
        $http.post('urlDeault', this, {
            code: "03020052",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        projectData: res.result.Data
                    })
                }
            }
        });
    }

    //删除
    handleDel(data) {
        var params = {
            params: [{
                id: data.id,
                userID: this.state.userData.userID
            }],
        }
        $http.post('urlDeault', this, {
            code: "03020051",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        hosPitalList: [],
                        associateDta: []
                    })
                    message.success('删除成功！')
                    this.loadData()
                }
            }
        });
    }

    //清空输入框
    clearInput() {
        this.setState({
            code: '',
            descripts: '',
            editData: '',
            stopDate: '',
            editStatus: false,
            leftRowData: ''
        })
    }

    clearRightInput() {
        this.setState({
            editRightData: '',
            rightId: '',
            rightStopDate: '',
            rightStartDate: ''
        })
    }

    /**
    * @ByShizi: 南昌红谷滩-医院管理员-排班类型优化
    * 需求 #534
    * Create 2022-04-14
    */
    handleAdd = () => {
        this.setState({
            rowId: "",
            associateDta: [],
            hosPitalList: []
        });
        this.clearRightInput();
        this.clearInput();
    }

    saveScheduling() {
        var params = {
            params: [{
                userID: this.state.userData.userID,//createUserDr -->userID
                code: this.state.code ? this.state.code : (this.state.editData ? this.state.editData.code : ''),
                descripts: this.state.descripts ? this.state.descripts : (this.state.editData ? this.state.editData.descripts : ''),
                startDate: moment(this.state.startDate).format(dayFormat),//生效时间
                stopDate: this.state.stopDate ? moment(this.state.stopDate).format(dayFormat) : '',//失效时间
                id: this.state.editData ? this.state.editData.id : ''

            }],
        }
        $http.post('urlDeault', this, {
            code: "03020050",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        code: '',
                        descripts: '',
                        editData: '',
                        stopDate: ''
                    })
                    message.success('保存成功！')
                    this.loadData()
                }
            }
        });
    }

    //初始化数据
    loadData = () => {
        let { page, pageSize, hospitalId } = this.state;
        this.setState({ loading: true })
        var params = {
            params: [{
                hospID: hospitalId,
                regTitle: this.state.regTitle,
                activeFlag: this.state.checked ? '1' : ''
            }],
            pagination: [{
                pageSize,
                currentPage: page
            }]
        }
        $http.post('urlDeault', this, {
            code: "03020004",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        dataSource: res.result.Data,
                        total: res.result.TotalCount,
                        page: page,
                        editStatus: false,
                        editData: '',
                        search: 'search',
                        loading: false
                    })
                } else {
                    this.setState({ loading: false })
                }
            }
        });
    }

    //点击坐诊类型，获取对应行的参数
    onClickRowData(data) {
        this.setState({
            leftRowData: data
        }, () => {
            this.loadAssociated()
            this.loadHospitalCode(1)
        })
    }

    //enter事件加载数据
    loadKeyDownData() {
        if (e.keyCode == '13') {
            this.loadData();
        }
    }

    //获取关联医院列表数据
    loadHospitalCode(page) {
        const { expenseType, leftRowData } = this.state;
        var params = {
            params: [
                {
                    regTitleID: leftRowData.id,//regTitleId -->regTitleID
                },
            ],
            pagination: [{
                pageSize: 10,
                currentPage: page
            }]
        }
        $http.post('urlDeault', this, {
            code: expenseType === '1' ? '03020030' : '03020067',
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        hosPitalList: res.result.Data
                    })
                } else {
                    this.setState({
                        hosPitalList: []
                    })
                }
            }
        });
    }

    //获取关联费用
    loadAssociated() {
        const { expenseType, leftRowData } = this.state;
        var params = {
            params: [
                {
                    regTitleID: leftRowData.id,
                    hospID: this.state.hospitalId ? this.state.hospitalId : this.state.userData.hospID,//hospId -->hospID
                },
            ],
        }
        $http.post('urlDeault', this, {
            code: expenseType === '1' ? '03020007' : '03020066',
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        associateDta: res.regTitleFee
                    })
                }
            }
        });
    }

    //获取医院信息
    loadHospitalMsg() {
        var params = {
            params: [{
                logonHospID: this.state.userData.hospID,
                logonGroupID: this.state.userData.groupID,
                hospRequired: '1'
            }]
        }
        $http.post('urlDeault', this, {
            code: "01040001",
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.setState({
                        hospitalData: res.depDoctor
                    })
                }
            }
        });
    }

    //关联医院费用数据删除
    handleRelationDel(data) {
        var { leftRowData, expenseType } = this.state;
        var params = {
            params: [{
                id: data.id,
                userID: this.state.userData.userID
            }]
        }
        $http.post('urlDeault', this, {
            code: expenseType === '1' ? '03020029' : '03020069',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    message.success('删除成功！！')
                    this.loadHospitalCode(1)
                }
            }
        });
    }

    onChange(e) {
        this.setState({ page: e }, () => {
            this.loadData();
        });
    }

    changePageSize(current, pageSize) {
        this.setState({ pageSize: pageSize, page: 1 }, () => {
            this.loadData();
        });
    }

    //添加关联医院
    AddhospitalData() {
        var { leftRowData, expenseType } = this.state;
        var date = new Date()
        var params = {
            params: [
                {
                    regTitleID: leftRowData.id,//regTitleId --》regTitleID
                    hospID: this.state.hospId ? this.state.hospId : this.state.userData.hospID,//hospId --》hospID
                    startDate: moment(date).format(dayFormat),
                    stopDate: '',//leftRowData.stopDate ? moment(leftRowData.stopDate).format(dayFormat) : '',
                    userID: this.state.userData.userID//createUserDr --> userID
                },
            ],
        }
        $http.post('urlDeault', this, {
            code: expenseType === '1' ? '03020028' : '03020068',
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.loadHospitalCode(1);
                    message.success('添加成功！')
                }
            }
        });
    }

    //保存关联费用
    handleSaveFee() {
        var { leftRowData, expenseType } = this.state;
        var date = new Date()
        var params = {
            params: [
                {
                    CBRTFParRef: leftRowData.id,
                    medID: this.state.medItemDr ? this.state.medItemDr : this.state.editRightData.medID,//medItemDr -->medID
                    startDate: this.state.rightStartDate ? moment(this.state.rightStartDate).format(dayFormat) : moment(date).format(dayFormat),
                    stopDate: this.state.rightStopDate ? moment(this.state.rightStopDate).format(dayFormat) :
                        (this.state.endStatus ? '' : (this.state.editRightData ? this.state.editRightData.stopDate : '')),//失效时间
                    id: this.state.editRightData ? this.state.editRightData.id : '',
                    userID: this.state.userData.userID//createUserDr -->userID
                },
            ],
        }
        $http.post('urlDeault', this, {
            code: expenseType === '1' ? '03020005' : '03020064',
            data: params,
            success: function (res) {
                if (res.errorCode === '0') {
                    this.loadAssociated();
                    message.success('添加成功！')
                    this.setState({
                        editRightData: '',
                        rightId: '',
                        rightStopDate: ''
                    })
                }
            }
        });
    }

    //切换医院，渲染排班列表
    handleSelectChange(name, e) {
        var id = '';
        if (e) {
            id = e.substring(e.indexOf('^') + 1)
        }
        this.setState({
            hospitalId: id
        }, function () {
            this.loadData()
            this.loadProjectData(id);
        })
    }

    //获取左列输入框的参数
    changeInputValue(e) {
        this.setState({
            regTitle: e.target.value
        })
    }

    changeChangeBox(e) {
        this.setState({
            checked: e.target.checked,
            page: 1
        }, () => {
            this.loadData()
        })
    }

    onRowClickRight = (record) => {
        return {
            onClick: () => {
                this.setState({
                    rightStartDate: '',
                    rightStopDate: '',
                    startStatus: false,
                    endStatus: false,
                    editRightData: record,
                    rightId: record.id
                })
            }
        }
    }

    //点击行，渲染当前行样式
    setRowRightClassName = (record) => {
        return record.id === this.state.rightId ? 'clickRowStyle' : '';
    }

    //点击行，渲染当前行样式
    onClickRow = (record) => {
        return {
            onClick: () => {
                if (this.state.rowId === "") {
                    this.setRowData(record);
                } else {
                    if (this.state.rowId !== record.id) {
                        this.setRowData(record);
                    } else {
                        this.handleAdd();
                    }
                }
            }
        };
    }

    setRowData = record => {
        this.setState({
            rowId: record.id,
            leftRowData: record,
            editRightData: '',
            editData: record,
            editStatus: true,
            code: record.code,
            descripts: record.descripts,
            startDate: record.startDate,
            stopDate: record.stopDate
        }, () => {
            this.loadAssociated()
            this.loadHospitalCode(1)
        });
    }

    //点击行，渲染当前行样式
    setRowClassName = (record) => {
        return record.id === this.state.rowId ? 'clickRowStyle' : '';
    }

    //获取生效时间
    getStartDate(e) {
        var a = moment(e, dayFormat).unix();
        var b = moment(this.state.stopDate ? this.state.stopDate : (this.state.editData ?
            (this.state.editData.stopDate ? moment(this.state.editData.stopDate, dayFormat) : '') : ''), dayFormat).unix()
        if ((a - b) > 10) {
            message.error('失效日期不能大于生效日期')
            return
        }
        this.setState({
            startDate: e
        })
    }

    //获取失效时间
    getStopDate(e) {
        var date = new Date()
        var a = moment(e, dayFormat).unix();
        var b = moment(this.state.startDate ? this.state.startDate : (this.state.editData ?
            moment(this.state.editData.startDate, dayFormat) : moment(date, dayFormat)),
            dayFormat).unix();
        if ((b - a) > 10) {
            message.error('失效日期不能大于生效日期')
            return
        }
        this.setState({
            stopDate: e
        })
    }

    changeRightStartDate(e) {
        var a = moment(e, dayFormat).unix();
        var b = moment(this.state.stopDate ? this.state.rightStopDate : (this.state.editRightData ?
            (this.state.editRightData.rightStopDate ? moment(this.state.editRightData.rightStopDate, dayFormat) : '') : ''), dayFormat).unix()
        if ((a - b) > 10) {
            message.error('失效日期不能大于生效日期')
            return
        }
        this.setState({
            rightStartDate: e,
            startStatus: true
        })
    }

    changeRightStopDate(e) {
        var date = new Date()
        var a = moment(e, dayFormat).unix();
        var b = moment(this.state.rightStartDate ? this.state.rightStartDate : (this.state.editRightData ?
            moment(this.state.editRightData.rightStartDate, dayFormat) : moment(date, dayFormat)),
            dayFormat).unix();
        if ((b - a) > 10) {
            message.error('失效日期不能大于生效日期')
            return
        }
        this.setState({
            rightStopDate: e,
            endStatus: true
        })
    }

    handleSelectHospChange(e) {
        var id = '';
        if (e) {
            id = e.substring(e.indexOf('^') + 1)
        }
        this.setState({
            hospId: id
        })
    }

    handleSelectProjectChange(e) {
        var id = '';
        if (e) {
            id = e.substring(e.indexOf('^') + 1)
        }
        this.setState({
            medItemDr: id,
            medItemDrName: e ? (e.substring(0, e.indexOf('^'))) : ''
        })
    }

    /**
    * @ByShizi: 类型切换 - 新增一个特殊复诊费维护功能
    * 需求 #
    * Create 2021-09-14
    * */
    handleExpenseTypeChange = key => {
        this.setState({
            expenseType: key,
            startStatus: false,
            endStatus: false,
            editRightData: '',
            rightId: '',
            rightStartDate: '',
            rightStopDate: '',
            medItemDr: '',
            medItemDrName: '',
        }, () => {
            this.loadAssociated()
            this.loadHospitalCode(1)
        })
    }

    render() {
        const { expenseType } = this.state;
        var date = new Date();
        //所属医院下拉参数
        let hospitalOption = [];
        this.state.hospitalData.map((item, index) => {
            hospitalOption.push(<Option key={index} code={item.descriptsSPCode} value={item.descripts + '^' + item.id}>{item.descripts}</Option>)
        })

        //获取项目名称下拉参数
        var projectOption = []
        this.state.projectData && this.state.projectData.map((item, index) => {
            projectOption.push(<Option key={index} code={item.descriptsSPCode} value={item.descripts + '^' + item.id}>{item.descripts}</Option>)
        })

        return (
            <div className='schedulingStyle table-body-height'>
                <div style={{ float: 'left', width: '25%', height: '100%', paddingRight: '6px', position: 'relative' }}>
                    <Card
                        bordered={false}
                        style={{ height: '30%' }}
                        title={(
                            <div className="card-title-left-icon">
                                <div></div>
                                {Util.isEmpty(this.state.leftRowData) ? '添加排班类型' : '编辑排班类型'}
                            </div>
                        )}
                    >
                        <div style={{ marginRight: '8%', textAlign: 'right' }}>
                            {/* <h4>{this.state.editData ? '编辑排班类型' : '添加排班类型'}</h4> */}
                            唯一代码：<Input placeholder='请输入唯一代码' style={{ width: '60%' }} maxLength={10}
                                value={this.state.code}
                                onChange={Util.commonInputChange.bind(this, 'code')} /><br />
                            <span style={{ color: 'red' }}>*</span>类型名称：
                            <Input placeholder='请输入10个字以内名称' style={{ width: '60%', marginTop: '5px' }}
                                value={this.state.descripts}
                                onChange={Util.commonInputChange.bind(this, 'descripts')} maxLength={10} /><br />
                            生效日期：<DatePicker format="YYYY-MM-DD" style={{ width: '60%', marginTop: '5px' }}
                                value={this.state.startDate ? moment(this.state.startDate, dayFormat) : ''}
                                onChange={this.getStartDate.bind(this)} /><br />
                            失效日期：<DatePicker format="YYYY-MM-DD" style={{ width: '60%', marginTop: '5px' }}
                                value={this.state.stopDate ? moment(this.state.stopDate, dayFormat) : ''}
                                onChange={this.getStopDate.bind(this)} />
                            <Button style={{ marginTop: '5px', marginLeft: '35%' }}
                                onClick={!Util.isEmpty(this.state.leftRowData) ? this.handleAdd : this.clearInput.bind(this)}>{!Util.isEmpty(this.state.leftRowData) ? '取消修改' : '清空'}</Button>
                            <Button className='saveButton' style={{ marginTop: '5px', marginLeft: '7%' }}
                                onClick={this.saveScheduling.bind(this)}>保存</Button>
                        </div>
                    </Card>
                    <div className="common-query-split-line" style={{ height: '8px' }}></div>
                    <Card
                        bordered={false}
                        style={{ height: 'calc(69% - 8px)' }}
                        title={<div className="card-title-left-icon"><div></div>搜索排班</div>}
                    >
                        <div className='table-body-height' style={{ marginRight: '10px', textAlign: 'right' }}>
                            医院名称：<Select placeholder="请选择所属医院" style={{ width: '69%' }}
                                defaultValue={this.state.userData.hospDesc}
                                showSearch
                                allowClear={true}
                                filterOption={(input, option) =>
                                    option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                }
                                onChange={this.handleSelectChange.bind(this, 'hospitalId')}
                                getPopupContainer={triggerNode => triggerNode.parentNode}>
                                {hospitalOption}
                            </Select><br />
                            类型名称/代码：<Input placeholder='输入类型名称或代码回车键查询' style={{ width: '49%', marginTop: '5px' }}
                                onChange={this.changeInputValue.bind(this)}
                                onKeyDown={this.loadKeyDownData.bind(this, 1)} />
                            <Checkbox style={{ marginLeft: '5px' }} checked={this.state.checked}
                                onChange={this.changeChangeBox.bind(this)} />仅显示生效
                            <Table
                                columns={this.leftColumn}
                                style={{ marginTop: 5, height: store.getState().tableHeight.y - 182 + 'px' }}
                                dataSource={this.state.dataSource} bordered
                                rowKey={(data) => {
                                    return data.id
                                }}
                                scroll={{ y: store.getState().tableHeight.y - 232 }}
                                onRow={this.onClickRow}
                                rowClassName={this.setRowClassName}
                                pagination={false}>
                            </Table>
                            <div id='position-page' >
                                <CommonPagination size={this.state.size} current={this.state.page} total={this.state.total} search={this.state.search}
                                    onShowSizeChange={this.changePageSize.bind(this)} complete={false} dataSource={this.state.dataSource}
                                    loading={this.state.loading} onChange={this.onChange.bind(this)} /></div>
                        </div>
                    </Card>
                    <div className="common-card-right-split-line" style={{ width: 8 }}></div>
                </div>
                <div style={{ float: 'right', width: '75%', height: '100%' }}>
                    <Tabs style={{ height: '46px' }} activeKey={expenseType} onChange={this.handleExpenseTypeChange}>
                        <TabPane tab="挂号诊查费" key="1"></TabPane>
                        <TabPane tab="特殊复诊费" key="2"></TabPane>
                    </Tabs>
                    <Card
                        type="inner"
                        size="small"
                        bordered={false}
                        title={<div className="card-title-left-icon"><div></div>设置关联费用</div>}
                    >
                        {/* <h4>{this.state.editRightData ? '编辑关联费用' : '添加关联费用'}</h4> */}
                        {/* <h4>{!Util.isEmpty(this.state.leftRowData) ? ('当前操作排班类型：' + ((this.state.leftRowData.code + '/' + this.state.leftRowData.descripts) || '')) : ''}</h4> */}
                        {/* <div style={{ textAlign: 'left', borderBottom: '1px solid #EEEEEE', padding: '5px 0px' }}>
                            <img className='scheduling-image' src={doctorImg} />
                            <span>当前操作排班类型：</span>
                        </div> */}
                        <div className="flex-align-items" style={{ marginBottom: '12px' }}>
                            <span style={{ color: 'red' }}>*</span>项目名称：<Select placeholder="请选择项目名称" style={{ width: '18%', marginTop: '5px' }}
                                disabled={this.state.editRightData ? true : false}
                                allowClear={true}
                                showSearch
                                filterOption={(input, option) =>
                                    option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                }
                                value={this.state.medItemDr ? this.state.medItemDrName : (this.state.editRightData ? this.state.editRightData.descripts : undefined)}
                                onChange={this.handleSelectProjectChange.bind(this)}
                                getPopupContainer={triggerNode => triggerNode.parentNode}>
                                {projectOption}
                            </Select>
                            <span style={{ marginLeft: '10px' }}><span style={{ color: 'red' }}>*</span>生效日期：</span>
                            <DatePicker format="YYYY-MM-DD" style={{ marginTop: '5px', width: '18%' }}
                                value={this.state.rightStartDate ? this.state.rightStartDate :
                                    (this.state.startStatus ? '' : (this.state.editRightData ? moment(this.state.editRightData.startDate, dayFormat)
                                        : moment(date, dayFormat)))}
                                onChange={this.changeRightStartDate.bind(this)} />
                            {/* <div> */}
                            <span style={{ marginLeft: '10px' }}>失效日期：</span>
                            <DatePicker format="YYYY-MM-DD" style={{ marginTop: '5px', width: '18%' }}
                                value={this.state.rightStopDate ? this.state.rightStopDate :
                                    this.state.endStatus ? '' : ((this.state.editRightData ? (this.state.editRightData.stopDate ?
                                        moment(this.state.editRightData.stopDate, dayFormat) : '') : ''))}
                                onChange={this.changeRightStopDate.bind(this)} />
                            <Button className='saveButton' style={{ marginTop: '5px', float: 'right', marginLeft: 10, marginRight: 10 }}
                                onClick={this.handleSaveFee.bind(this)}>保存</Button>
                            <Button style={{ marginTop: '5px', float: 'right', marginLeft: 10 }}
                                onClick={this.clearRightInput.bind(this)}>{!Util.isEmpty(this.state.editRightData) ? '取消' : '清空'}</Button>
                        </div>
                        <Table
                            columns={this.columns}
                            dataSource={this.state.associateDta}
                            loadData={this.loadAssociated.bind(this)}
                            onRow={this.onRowClickRight}
                            rowClassName={this.setRowRightClassName}
                            bordered
                            rowKey={(data) => {
                                return data.id
                            }}
                            pagination={false}
                            scroll={{ y: store.getState().tableHeight.y / 2 - 80 }}
                        >
                        </Table>
                    </Card>
                    <Card
                        type="inner"
                        size="small"
                        bordered={false}
                        title={<div className="card-title-left-icon"><div></div>设置关联医院</div>}
                    >
                        <Table
                            columns={this.sumSolumns}
                            dataSource={this.state.hosPitalList}
                            loadData={this.loadData}
                            bordered
                            rowKey={(data) => {
                                return data.id
                            }}
                            title={() => {
                                return <div style={{ textAlign: 'right' }}>
                                    {/* <span style={{ fontWeight: 'bold' }}>关联医院</span> */}
                                    <div>
                                        医院名称：<Select placeholder="请选择所属医院" style={{ width: '200px' }}
                                            defaultValue={this.state.userData.hospDesc}
                                            onChange={this.handleSelectHospChange.bind(this)}
                                            showSearch
                                            allowClear={true}
                                            getPopupContainer={triggerNode => triggerNode.parentNode}>
                                            {hospitalOption}
                                        </Select>
                                        <Button className='saveButton' style={{ marginLeft: '10px', marginTop: '0px', marginRight: 10 }}
                                            onClick={this.AddhospitalData.bind(this)}>加入</Button>
                                    </div>
                                </div>
                            }}
                            pagination={false}
                            scroll={{ y: store.getState().tableHeight.y / 2 - 60 }}
                        >
                        </Table>
                    </Card>
                </div>
            </div>
        )
    }
};

export default Form.create()(Scheduling);